<template>
  <div v-show="show">
    <div v-if="needBg" class="load-mask"></div>
    <div class="loading"></div>
  </div>
</template>

<script>
export default {
  name: "Loading",
  data() {
    return {
      show: false,
      needBg: false,
    };
  },
};
</script>

<style lang="scss" scoped>
.load-mask {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 999;
  line-height: 100vh;
  text-align: center;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  overflow: hidden;
}
.loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  z-index: 1000;
  background: conic-gradient(#2587f2, 30%, white);
  --mask: radial-gradient(closest-side, transparent 75%, black 76%);
  -webkit-mask-image: var(--mask);
  mask-image: var(--mask);
  animation: rotate 1s linear infinite reverse;
}

@keyframes rotate {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }

  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}
</style>